package tk.mybatis.springboot.share.util;
import java.security.MessageDigest;
public class MD5Helper {
	public static String EncoderByMd5(String str,String  key){
        str += "&key=" + key;
        try {
            MessageDigest md5=MessageDigest.getInstance("MD5");
            byte[] bs = md5.digest(str.getBytes());
            StringBuilder sb = new StringBuilder(40);
            for (byte x : bs)
            {
                if ((x & 0xff) >> 4 == 0)
                {
                    sb.append("0").append(Integer.toHexString(x & 0xff));
                }
                else
                {
                    sb.append(Integer.toHexString(x & 0xff));
                }
            }
            return sb.toString().toUpperCase();
        }catch (Exception e)
        {
            return  "";
        }

    }
}
